import Vue from 'vue'
import Vant, { Lazyload } from 'vant'
import MuseUI from 'muse-ui'

import 'muse-ui/dist/muse-ui.css'

import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import index from '@/views/pages/index/index'
import postDetail from '@/views/pages/post/detail'
// import creatPost from '@/views/pages/post/creatPost'
import UserDetail from '@/views/pages/my/userDetail'
import myHost from '@/views/pages/my/myHost'
import myStarHost from '@/views/pages/my/myStarHost'
import myLikeHost from '@/views/pages/my/myLike'
import myCommentHost from '@/views/pages/my/myCommentHost'
import ChangeUserInfo from '@/views/pages/my/changeUserInfo'
import ChangePassword from '@/views/pages/my/changePassword'
import SafetyProblem from '@/views/pages/my/safetyProblem'
import noticeDetail from '@/views/pages/notice/noticeDetail'
import moreNotice from '@/views/pages/notice/moreNotice'
import search from '@/views/pages/home/search'
import login from '@/views/login'
import register from '@/views/register'
import 'vant/lib/index.css'

Vue.use(Router)
Vue.use(Vant)
Vue.use(MuseUI)
Vue.use(Lazyload)

const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 配置首页路由
    {
      path: '/index',
      name: 'index',
      component: index,
      meta: {
        keepAlive: true,
        needLogin: true //需要加校检判断的路由
      }
      // children: [
      //   // 帖子详情页
      //   {
      //     path: 'postDetail',
      //     name: 'postDetail',
      //     component: postDetail
      //   }
      // ]
    },
    // // 发布帖子
    // {
    //   path: '/index/creatPost',
    //   name: 'creatPost',
    //   component: creatPost
    // },
    // 帖子详情页
    {
      path: '/index/postDetail',
      name: 'postDetail',
      component: postDetail,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 用户详情页
    {
      path: '/index/UserDetail',
      name: 'UserDetail',
      component: UserDetail,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 我的帖子页
    {
      path: '/index/myHost',
      name: 'myHost',
      component: myHost,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 我的收藏页
    {
      path: '/index/myStarHost',
      name: 'myStarHost',
      component: myStarHost,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 我的点赞页
    {
      path: '/index/myLikeHost',
      name: 'myLikeHost',
      component: myLikeHost,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 我的评论页
    {
      path: '/index/myCommentHost',
      name: 'myCommentHost',
      component: myCommentHost,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 修改用户信息页
    {
      path: '/index/ChangeUserInfo',
      name: 'ChangeUserInfo',
      component: ChangeUserInfo,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 修改账号密码 回答问题
    {
      path: '/index/SafetyProblem',
      name: 'SafetyProblem',
      component: SafetyProblem,
      meta: {
        // needLogin: true, //需要加校检判断的路由
        keepAlive: true
      },
    },
    // 修改账号密码 回答问题
    {
      path: '/login/SafetyProblem',
      name: 'SafetyProblem',
      component: SafetyProblem,
      meta: {
        keepAlive: true
      },
    },
    // 修改账号密码 修改密码
    {
      path: '/index/SafetyProblem/ChangePassword',
      name: 'ChangePassword',
      component: ChangePassword
    },
    // 修改账号密码 修改密码
    {
      path: '/login/SafetyProblem/ChangePassword',
      name: 'ChangePassword',
      component: ChangePassword
    },
    // 配置登录页面路由
    {
      path: '/login',
      name: 'login',
      component: login,
      meta: {
        keepAlive: true //需要加校检判断的路由
      },
    },
    // 配置注册页面路由
    {
      path: '/register',
      name: 'register',
      component: register
    },
    // 配置公告详情页路由
    {
      path: '/index/noticeDetail',
      name: 'noticeDetail',
      component: noticeDetail,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 配置公告列表详情页路由
    {
      path: '/index/moreNotice/noticeDetail',
      name: 'noticeDetail',
      component: noticeDetail,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 配置公告列表页路由
    {
      path: '/index/moreNotice',
      name: 'moreNotice',
      component: moreNotice,
      meta: {
        needLogin: true //需要加校检判断的路由
      },
    },
    // 配置搜索路由
    {
      path: '/index/search',
      name: 'search',
      component: search,
      meta: {
        keepAlive: true,
        needLogin: true //需要加校检判断的路由
      }
    }
  ]
})

